<?php
/**
 * 常量定义与主程序引入
 * @copyright 2020-2021 WillPHP
 * @author NoMind<24203741@qq.com/113344.com>
 * @version WillPHPv3
 * @since 2021-12-01
 */
header('Content-type: text/html; charset=utf-8'); //设置编码
defined('WIPHP_URI') or die('Access Denied'); //包含检测
version_compare(PHP_VERSION, '5.6', '<') and die('YiYuPHP requires PHP 5.6 or newer.'); //判断PHP版本
define('START_TIME', microtime(true)); //初始运行时间
define('SYS_TIME', $_SERVER['REQUEST_TIME']); //当前时间
date_default_timezone_set('PRC'); //设置默认时区
define('WIPHP_VER', 'v3.0beta'); //框架版本号
define('__WIPHP__', 'WillPHP '.WIPHP_VER); //框架名称+版本号
defined('URL_MODEL') or define('URL_MODEL', 1); //URL模式: 1=>普通模式(默认)，2=>隐藏index.php(伪静态)
defined('APP_NAME') or define('APP_NAME', str_replace(strrchr(basename($_SERVER['SCRIPT_FILENAME']), '.'),'',basename($_SERVER['SCRIPT_FILENAME']))); //默认应用名称
defined('THEME_ON') or define('THEME_ON', false); //默认关闭多主题
defined('APP_DEBUG') or define('APP_DEBUG', false); //默认关闭调试
defined('CACHE_TYPE') or define('CACHE_TYPE', 1); //默认数据缓存类型 1.phpfile;2.serialize
defined('URL_SUFFIX') or define('URL_SUFFIX', '.html'); //默认URL后缀
define('PATH_CORE', WIPHP_PATH.'/wiphp'); //定义框架核心路径
define('PATH_ADDONS', WIPHP_URI.'/addons'); //定义插件路径
define('PATH_EXTEND', WIPHP_URI.'/extend'); //定义扩展类库路径
define('APP_DIR', WIPHP_URI.'/app'); //定义应用所在目录
define('APP_NAMESPACE', 'app\\'.APP_NAME); //当前应用命名空间
define('APP_PATH', WIPHP_URI.'/app/'.APP_NAME); //定义当前应用目录
defined('PATH_VIEW') or define('PATH_VIEW', APP_PATH.'/view'); //定义模板文件路径
define('PATH_RUNTIME', WIPHP_URI.'/runtime/'.APP_NAME); //定义编译运行路径
define('PATH_CACHE', PATH_RUNTIME.'/data'); //定义数据缓存路径
define('PATH_LOG', PATH_RUNTIME.'/log'); //定义错误日志路径
define('PATH_VIEWC', PATH_RUNTIME.'/viewc'); //定义模板编译路径
define('PATH_SHTML', PATH_RUNTIME.'/shtml'); //定义模板缓存路径
define('__ROOT__', rtrim(strtr(dirname($_SERVER['SCRIPT_NAME']), '\\', '/'), '/')); //网站根目录
define('__STATIC__', __ROOT__.'/static'); //公共静态资源目录
define('__UPLOAD__', __ROOT__.'/uploads'); //公共上传目录
define('__URL__', (URL_MODEL == 2)? str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']) : $_SERVER['SCRIPT_NAME']); //基础URL
define('__REFERER__', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
defined('SESSION_ON') or define('SESSION_ON', true); //默认开启session
if (SESSION_ON && !session_id()) session_start(); //判断开启session
require WIPHP_PATH.'/helper.php'; //载入助手函数库
if (file_exists(WIPHP_URI.'/app/common.php')) require WIPHP_URI.'/app/common.php'; //载入用户函数库
require PATH_CORE.'/App.php'; //载入框架主程序
\wiphp\App::start(); //运行框架